package cn.idietrade.idietradegoodsmodule8002.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author zjy
 * @version 1.0
 * @createTime 2022-12-06 16:05
 * @description
 */
@Configuration
public class RabbitMQConfig {
    /**
     * 创建一个同步数据队列
     * @return
     */
    @Bean
    public Queue syncQueue(){
        return new Queue("syncQueue");
    }
    /**
     * 创建一个直连交换机
     * @return
     */
    @Bean
    public DirectExchange syncDirectExchange(){
        return new DirectExchange("syncExchange");
    }

    /**
     * 绑定队列和交换机
     * @return
     */
    @Bean
    public Binding testBinding(){
        return BindingBuilder.bind(syncQueue()).to(syncDirectExchange()).with("sync");
    }
}
